<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Arsip_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
		$this->CI = get_instance();
	}
	
	function get_arsip_grid(){	
		$this->db->select('*');
		$this->db->from('ARSIP.ARSIP');
		$this->db->where('ARSIP_STATUS',1);
		$this->CI->flexigrid->build_query();
		
		$return['records'] = $this->db->get();
		
		$this->db->select('*');
		$this->db->from('ARSIP.ARSIP');
		$this->db->where('ARSIP_STATUS',1);
		$this->CI->flexigrid->build_query(FALSE);
		
		$return['record_count'] = $this->db->count_all_results();

		return $return;
	}

	function count_all_arsip(){
		$this->db->select('*');
		$this->db->from('ARSIP');
		$query = $this->db->get();
		return $query->num_rows();
	}

	function get_all_arsip(){
		$this->db->select('*');
		$this->db->from('ARSIP');
		$query = $this->db->get();
		return $query->result();
	}

	function get_all_by_id($tahun,$id)
	{
		$this->db->select('*');
		$this->db->from('ARSIP');
		$this->db->where('ARSIP_TAHUN',$arsip_tahun);
		$this->db->where('ARSIP_ID',$arsip_id);
		$query = $this->db->get();
		return $query->result();
		
	}

	function get_arsipID($arsip_tahun,$arsip_id){
		$this->db->select('*');
		$this->db->from('ARSIP');
		$this->db->where('ARSIP_TAHUN',$arsip_tahun);
		$this->db->where('ARSIP_ID',$arsip_id);
		$query = $this->db->get();
		return $query->result();
	}

	function insert_arsip($data){
		$this->db->insert('ARSIP',$data);
	}

	function update_arsip($data,$arsip_tahun,$arsip_id){
		$this->db->where('ARSIP_TAHUN',$arsip_tahun);
		$this->db->where('ARSIP_ID',$arsip_id);
		$this->db->update('ARSIP',$data);
	}

	function delete_arsip($arsip_tahun,$arsip_id){
		$data = array(
			'ARSIP_STATUS'		=> 0
		);
		$this->db->where('ARSIP_TAHUN',$arsip_tahun);
		$this->db->where('ARSIP_ID',$arsip_id);
		$this->db->update('ARSIP',$data);
	}
}

?>